<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class UserChPass extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'old_pass' => 'bail|required|regex:/^[A-Za-z0-9]+$/',
            'password' => 'bail|required|between:6,20|confirmed|regex:/^[A-Za-z0-9]+$/',
        ];
    }
    public function messages()
    {
        return [
            'old_pass.required' => '请输入原密码',
            'old_pass.regex' => '密码的数据类型仅为字母和数字',
            'password.regex' => '密码的数据类型仅为字母和数字',
            'password.confirmed'=>'两次输入密码不一致',
            'password.between'=>'密码长度必须在6到20位之间'
        ];
    }
}
